package com.neuedu.web;

import com.neuedu.pojo.Comments;
import com.neuedu.service.CommentsService;
import com.neuedu.service.CommentsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@WebServlet(name = "ArticleReplyServlet",urlPatterns = "/article/reply")
public class ArticleReplyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取参数
        String uid = request.getParameter("uid");
        String aid = request.getParameter("aid");
        String commcontent = request.getParameter("commcontent");
        Date commtime = new Date();
        // 封装
        Comments comments = new Comments();
        comments.setUid(Long.parseLong(uid));
        comments.setAid(Long.parseLong(aid));
        comments.setCommcontent(commcontent);
        comments.setCommtime(commtime);
        //调service
        CommentsService commentsService = new CommentsServiceImpl();
        int num = commentsService.addComment(comments);
        response.getWriter().println(num);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
